<?php
/**
 * Created by IntelliJ IDEA.
 * User: wanglu
 * Date: 17/4/12
 * Time: 17:43
 */
class Lang_user_model extends BaseModel {


    function __construct()
    {
        parent::__construct(Db_model::TABLE_PROJECT_LANG_USER);
    }


    public function get_user_langs($pid, $user_id) {

        return $this->db->select(Db_model::TABLE_PROJECT_LANG . ".*, ". Db_model::TABLE_PROJECT_LANG_USER . ".permission, " . Db_model::TABLE_PROJECT_LANG_USER . ".lang_id")
            ->from(Db_model::TABLE_PROJECT_LANG_USER)
            ->join(Db_model::TABLE_PROJECT_LANG, Db_model::TABLE_PROJECT_LANG_USER.'.lang_id='.Db_model::TABLE_PROJECT_LANG.'.id')
            ->order_by(Db_model::TABLE_PROJECT_LANG . ".createtime", "ASC")
            ->order_by(Db_model::TABLE_PROJECT_LANG_USER . ".permission", "DESC")
            ->where(Db_model::TABLE_PROJECT_LANG_USER. ".uid", $user_id)
            ->where(Db_model::TABLE_PROJECT_LANG_USER. ".pid", $pid)
            ->get()->result_array();
    }

}